{extend name='base' /}
{block name='title'}个人中心{/block}
{block name='main'}
<link rel="stylesheet" href="__CSS__/booklist.css">
<link rel="stylesheet" href="__CSS__/booktable.css">
<style>
    .main {
        background: url("__IMG__/list_bg.jpg") left top repeat-y;
    }
</style>
<div class="row m-0 mt-3 main">
    {include file='user/user_left'}
    <div class="right flex-1">
        <table class="tb w-100">
            <thead>
            <tr>
                <th colspan="2">商品信息</th>
                <th>数量</th>
                <th>订单金额</th>
                <th>状态</th>
            </tr>
            </thead>
            <tbody>
            {foreach $order as $k => $g}
            <tr bgcolor="#F5F5F5">
                <td colspan="6">
                    <span class="float-right">
                        {if $g['status'] == 2}
                        <a class="card-link t" href="javascript:void(0);" onclick="finishOrder('{$g["id"]}')">确认完成</a>&nbsp;&nbsp;|&nbsp;&nbsp;
                        {elseif $g['status'] == 3}
                        <a class="d" href="javascript:void(0);" onclick="delOrder('{$g["id"]}')">删除订单</a>&nbsp;&nbsp;|&nbsp;&nbsp;
                        {/if}
                        <a class="t" href="{:url('User/orderinfo', array('id' => $g['id']))}">订单详情</a>
                    </span>
                    <span class="float-left">{$g['update_entered']}</span>
                </td>
            </tr>
            {foreach $g['goods'] as $ks => $v}
            <tr>
                <td width="70">
                    <img src="{$v['thumb']}" class="book-img">
                </td>
                <td><a href="{:url('Book/info', array('bookid' => $v['bookid']))}">{$v['bname']}</a></td>
                <td>{$v['number']}</td>
                <td>{if $ks==0}{$g['amount']}{/if}</td>
                <td>
                    {if $g['status'] == 1}
                    <span class="text-danger">待发货</span>
                    {elseif $g['status'] == 2}
                    <span class="text-info">待收货</span>
                    {else}
                    <span class="text-success">已完成</span>
                    {/if}
                </td>
            </tr>
            {/foreach}
            {/foreach}
            </tbody>
        </table>
    </div>
</div>
{/block}

{block name='js'}
<script>
    function delOrder(id) {
        common("你确定要删除该订单吗？", "{:url('Order/del')}?id="+id);
    }

    function finishOrder(id) {
        common("你确定要完成该订单吗？", "{:url('Order/finish')}?id="+id);
    }
</script>
{/block}